<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %><%--
  Created by IntelliJ IDEA.
  User: pkuschool
  Date: 2021/4/15
  Time: 5:03 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>显示当前日期和时间</title>
</head>
<body>

<h1>显示当前日期和时间</h1>

<%
    Date date = new Date();
    out.println("<h2 align=\"center\">" + date.toString() + "</h2>");
%>

<h1>显示当前格式化的日期和时间</h1>

<%
    SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    out.println("<h2 align=\"center\">" + ft.format(date) + "</h2>");
%>

</body>
</html>
